﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace SaladBar.Domain
{
    [Serializable()]
    public class PersistentObject
    {
        public virtual int Id { get; set; }
        public virtual DateTime CreateDate { get; set; }
        public virtual DateTime UpdateDate { get; set; }

        public PersistentObject()
        {
            this.CreateDate = DateTime.Now;
        }

        public virtual bool Equals(PersistentObject obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            return obj.Id == Id;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (PersistentObject)) return false;
            return Equals((PersistentObject) obj);
        }

        public override int GetHashCode()
        {
            return Id;
        }
    }
}
